package com.yshye.adapter.wiki;

import java.util.List;

import sun.util.logging.resources.logging;

public class Adapter implements LogDBOperateApi {
	private LogFileOperateApi adadtee;
	
	public Adapter(LogFileOperateApi adadtee) {
		this.adadtee = adadtee;
	}
	

	public void createLog(LogModel model) {
		
List<LogModel> list = adadtee.readLogFile();
list.add(model);
adadtee.writeLogFile(list);

	}

	public void updateLog(LogModel model) {
		List<LogModel> list = adadtee.readLogFile();
		for (int i = 0; i < list.size(); i++) {
			if (list.get(i).getLogid().equals(model.getLogid())) {
				list.set(i, model);
				break;
			}
		}
		adadtee.writeLogFile(list);

	}

	public void removeLog(LogModel model) {
		List<LogModel> list = adadtee.readLogFile();
		list.remove(model);
		adadtee.writeLogFile(list);

	}

	public List<LogModel> getAll() {
		return adadtee.readLogFile();
	}

}
